|
|
|
|
|
|
|
Public Property Get HighValue() As Variant
'
HighValue = m_HighValue
'
End Property
Public Property Let HighValue(ByVal vNewValue As Variant)
'
If IsNumeric(vNewValue) = False Then
Error 380 ' invalid property
Else
m_HighValue = vNewValue
PropertyChanged "HighValue"
End If
'
End Property |
|
|
|
|
|
|
|
|
Notice how the HighValue and LowValue Let routines handle the incoming value. First, the parameter is checked to see if it can pass as a numeric value. If not, an error is invoked. If the parameter can be converted into numeric data, the value is stored and the PropertyChanged method is used to mark the item. |
|
|
|
|
| |
|
|
|
|
When reporting an error from within an ActiveX control, it is always better to "raise" an error using the Error keyword than to display a custom message box. Custom message boxes can get in the way of the host program interface at either runtime or design time. However, using the Error method to report an error is handled appropriately by the host development tool. |
|
|
|
|
|
|
|
|
|
|
After adding the new properties to the file, you need to update the InitProperties event to reflect the new default values for the range-checking properties. Listing 5.25 shows how this is done. Add this code to the end of the InitProperties event. |
|
|
|
|
|
|
|
|
Listing 5.25. Adding the range-checking properties to the InitProperties event. |
|
|
|
|
|
|
|
|
'
' InRange properties
m_CheckRange = m_def_CheckRange
m_HighValue = m_def_HighValue
m_LowValue = m_def_LowValue |
|
|
|
|
|